home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2003 November / PCWK1103B.iso / DesignCAD 3D Max PLUS trial 30 / DATA1.CAB / Example_Files / Sample_Macros / 600_3_InfoL.d3m < prev    next >
Encoding:
Text File  |  2003-09-29  |  10.1 KB  |  542 lines

  1. ' This is the third macro in the 600 series, which creates the
  2. ' large material boxes. 
  3. '
  4. ' Get Values from data file.
  5. '
  6. ' Based on RType chosen by user above
  7.         open "i", 1, "*\sample macros\600.txt"
  8. ' Assign #s found to Variables
  9.     Input #1, AddLen
  10.     Input #1, TH
  11.     Input #1, PanNum2
  12.     Input #1, PanNum
  13. ' Close File
  14.     Close #1
  15. '
  16. ' Routine to Calculate values for Large Info Boxes
  17.   Calc1:
  18.       ' Calculate and display MTee
  19.         Precision 2    
  20.         MTeeN = Area1 * 0.286
  21.         MTeeC = MTeeN / 25
  22.         MTeeN2 = ROUND(MTeeN)
  23.         ' MTeeC2 = ROUND(MTeeC)
  24.         MTemp = MTeeC + .5
  25.         MTeeC2 = ROUND(MTemp)
  26.         '
  27.     ' Calculate and display 1.2CN
  28.         CN12 = Area1 * 1.65
  29.         CNC12 = CN12 / 75
  30.         ' CN122 = CN12
  31.         CN122 = ROUND(CN12)
  32.         '  CNC122 = CNC12
  33.         CTemp = CNC12 + .5
  34.         CNC122 = ROUND(CTemp)
  35.         '
  36.     ' Calculate and display 1.6CN
  37.         CN6 = Area1 * 1.61
  38.         CN6C = CN6 / 75
  39.           CN62 = ROUND(CN6)
  40.         ' CN62 = ROUND(CN6)
  41.          ' CN6C2 = CN6C
  42.         C6Temp = CN6C + .5
  43.         CN6C2 = ROUND(C6Temp)
  44.         '
  45.     ' Calculate and display ST Fix
  46.         STFix = Area1 * 0.765
  47.         STFixC = STFix / 100
  48.         STFixD = STFixC + .5
  49.         'STFixC = ROUND(STFixD)
  50.                 STFixC2 = STFixC
  51.         STFix2 = ROUND(STFix)
  52.     ' Calculate and display Rods T
  53.         RodsT = Area1 * 0.765
  54.         RodsTC = RodsT / 100
  55.         RodsTD = RodsTC + .5
  56.         'RodsTC = ROUND(RodsTD)
  57.         RodsTC2 = RodsTC
  58.     ' Calculate and display Rods B
  59.         RodsB = Area1 * 0.765
  60.         RodsBC = RodsB / 100
  61.         RodsBD = RodsBC + .5
  62.         'RodsBC = ROUND(RodsBD)
  63.         RodsBC2 = RodsBC
  64.     ' Calculate and display Channel
  65.     ' Apply Channel Adjustment from Earlier
  66.         Chan = Chan + AddLen
  67.         Chan = Len1 / 3
  68.         Chan2 = ROUND(Chan)
  69.         Chan2C = Chan / 24
  70.         'ChTemp = Chan2C + .5
  71.         'Chan2C = ROUND(ChTemp)
  72.     ' Resolve Panel Choice for the user
  73.         Panel = .36
  74.     ' Calculate and display Panels
  75.         Ar = Area1 * 0.065
  76.         Pan1 = Area1 + Ar
  77.         Pan2 = Pan1 / Panel
  78.         Pan3 = Pan2
  79.         Precision 2
  80.     ' Apply Panel Reduction
  81.         Pan3 = Pan3 - PanNum2    
  82.         Precision 2
  83.         PTemp = Pan3 + .05
  84.     '    Pan3 = ROUND(PTemp)
  85.         '
  86. ' Section to Create Large Info Box
  87.   Info1:
  88.     ' Silent Mode On
  89.         Sys(36) = 1
  90.     '
  91.     ' Open New DesignCAD Drawing
  92.         >New
  93.         {
  94.         }
  95.         '
  96.     ' Make Layer 11 the current layer
  97.         Layer(11) = 14
  98.     '
  99.     ' Create String Variables for Text Block
  100.     ' Variables in the No. Column need to be integers only
  101.         Precision 0
  102.         MTeeN2$ = MTeeN2
  103.         CNC122$ = CN122
  104.         CN62$ = CN62
  105.         STFix2$ = STFix
  106.         RodsT2$ = RodsT
  107.         RodsB2$ = RodsB
  108.         Chan2$ = Chan2
  109.     ' Variables in the CTS column need one place precision
  110.         Precision 1
  111. ' Straight Unmodified Variables
  112.         MTeeC2$ = MTeeC
  113.         CN122$ = CNC12
  114.         CN6C2$ = CN6C
  115.         STFixC2$ = STFixC
  116.         RodsTC2$ = RodsTC
  117.         RodsBC2$ = RodsBC
  118.         Chan2C$ = Chan2C
  119.         Pan3$ = Pan3
  120. ' Rounded Variables
  121. '        MTeeC2$ = MTeeC2
  122. '        CN122$ = CNC122
  123. '        CN6C2$ = CN6C2
  124. '        STFixC2$ = STFixC2
  125. '        RodsTC2$ = RodsTC2
  126. '        RodsBC2$ = RodsBC2
  127. '        Chan2C$ = Chan2C
  128. '        Pan3$ = Pan3
  129. '
  130. ' Half Text height
  131.         HTH = TH / 2
  132.     ' Set Spacing for all text blocks at 1, DO NOT CHANGE THIS !!
  133.         SP = 1
  134.     ' Default Value
  135.         Six = 1
  136.     ' Draw First Labels for Info Box
  137.     if Six = 1 then
  138.     ' Text Block with 0.6
  139.         >TextBlock
  140.         {
  141.         <Style 0
  142.         <size [TH]
  143.         <Distance [SP]
  144.         <TextBegin
  145.         <Text "   "
  146.         <Text " T  "
  147.         <Text "1.2 "
  148.         <Text "0.6 "
  149.         <Text "Fix "
  150.         <Text "T R "
  151.         <Text "B R "
  152.         <Text "Ch "
  153.         <justification 1    
  154.         <pointxyz 0, 0, 0    
  155.         }
  156.     else
  157.     ' Text Block without 0.6
  158.         >TextBlock
  159.         {
  160.         <Distance [SP]
  161.         <TextBegin
  162.         <Text "   "
  163.         <Text " T  "
  164.         <Text "1.2 "
  165.         <Text "    "
  166.         <Text "Fix "
  167.         <Text "T R "
  168.         <Text "B R "
  169.         <Text "Ch "
  170.         <justification 1
  171.         <pointxyz 0, 0, 0
  172.         }
  173.     end if
  174.     ' Set Color to Red
  175.         Sys(300) = 255
  176.         Sys(301) = 0
  177.         Sys(302) = 0
  178.     '
  179.     ' Draw Number Column Values
  180.     if Six = 1 then
  181.     ' Text Block with 0.6
  182.         >TextBlock
  183.         {
  184.         <Distance [SP]
  185.         <TextBegin
  186.         <Text "   "
  187.         <Text [MTeeN2$]
  188.         <Text [CNC122$]
  189.         <Text [CN62$]
  190.         <Text [STFix2$]
  191.         <Text [RodsT2$]
  192.         <Text [RodsB2$]
  193.         <Text [Chan2$]
  194.         <justification 1
  195.         <pointxyz [HTH * 8], 0, 0
  196.         }
  197.     else
  198.     ' Text block without 0.6
  199.         >TextBlock
  200.         {
  201.         <Distance [SP]
  202.         <TextBegin
  203.         <Text "   "
  204.         <Text [MTeeN2$]
  205.         <Text [CNC122$]
  206.         <Text "   "
  207.         <Text [STFixC2$]
  208.         <Text [RodsT2$]
  209.         <Text [RodsB2$]
  210.         <Text [Chan2$]
  211.         <justification 1
  212.         <pointxyz [HTH * 8], 0, 0
  213.         }
  214.     end if
  215.     ' Draw CTS Column Values
  216.     if Six = 1 then
  217.     ' Text Block with 0.6
  218.         >TextBlock
  219.         {
  220.         <Distance [SP]
  221.         <TextBegin
  222.         <Text "   "
  223.         <Text [MTeeC2$]
  224.         <Text [CN122$]
  225.         <Text [CN6C2$]
  226.         <Text [STFixC2$]
  227.         <Text [RodsTC2$]
  228.         <Text [RodsBC2$]
  229.         <Text [Chan2C$]
  230.         <justification 1
  231.         <pointxyz [HTH * 16], 0, 0
  232.         }
  233.     else
  234.     ' Text Block without 0.6
  235.         >TextBlock
  236.         {
  237.         <Distance [SP]
  238.         <TextBegin
  239.         <Text "   "
  240.         <Text [MTeeC2$]
  241.         <Text [CN122$]
  242.         <Text "   "
  243.         <Text [STFix2C$]
  244.         <Text [RodsTC2$]
  245.         <Text [RodsBC2$]
  246.         <Text [Chan2C$]
  247.         <justification 1
  248.         <pointxyz [HTH * 16], 0, 0
  249.         }
  250.     end if
  251.     ' Set Color back to normal
  252.         Sys(300) = ccRed
  253.         Sys(301) = ccGreen
  254.         Sys(302) = ccBlue
  255.     '
  256.     ' Text Title Block for Ref
  257.         >TextBlock
  258.         {
  259.         <Distance [SP]
  260.         <Style 0
  261.         <TextBegin
  262.         <Text "Ref"
  263.         <justification 1    
  264.         <pointxyz 0, 0, 0    
  265.         }
  266.     ' Text Block for No
  267.         >TextBlock
  268.         {
  269.         <Distance [SP]
  270.         <TextBegin
  271.         <Style 0
  272.         <Text "no"
  273.         <justification 1
  274.         <pointxyz [HTH * 8], 0, 0
  275.         }
  276.     ' Text block for cts
  277.         >TextBlock
  278.         {
  279.         <Distance [SP]
  280.         <TextBegin
  281.         <Style 0
  282.         <Text "cts"
  283.         <justification 1
  284.         <pointxyz [HTH * 16], 0, 0
  285.         }
  286. ' Set Current Line Type to Zero
  287.     Sys(6) = 0
  288.     '
  289.     ' Draw Title Block Box
  290.         >Box
  291.         {
  292.         <Pointxyz [-TH*2], [TH/2], 0
  293.         <Pointrel [TH*12], [-TH*2], 0
  294.         }
  295.         '
  296.     ' Draw First 3 value Box
  297.         >Box
  298.         {
  299.         <Pointxyz [-TH*2], [-TH*1.5], 0
  300.         <Pointrel [TH*12], [-TH*6], 0
  301.         }
  302.         '
  303.     ' Update Current Y Value 
  304.         CurY = TH*1.5
  305.         CurY = CurY + TH*6
  306.         '
  307.     ' Draw second 3 value Box
  308.         >Box
  309.         {
  310.         <Pointxyz [-TH*2], [-CurY], 0
  311.         <Pointrel [TH*12], [-TH*6], 0
  312.         }
  313.         '
  314.     ' Update Current Y Value
  315.         CurY = CurY + TH*6
  316.         '
  317.     ' Draw Channel Box
  318.         >Box
  319.         {
  320.         <Pointxyz [-TH*2], [-CurY], 0
  321.         <Pointrel [TH*12], [-TH*2], 0
  322.         }
  323.         '
  324.     ' Update Current Y Value
  325.         CurY = CurY + TH*2
  326.         '
  327.     ' Draw Left Column Line
  328.         >Line
  329.         {
  330.         <Pointxyz [TH*2], [TH/2], 0
  331.         <Pointxyz [TH*2], [-CurY], 0
  332.         }
  333.         '
  334.     ' Draw Right Column Line
  335.         >Line
  336.         {
  337.         <Pointxyz [TH*6], [TH/2], 0
  338.         <Pointxyz [TH*6], [-CurY], 0
  339.         }
  340.     '
  341.     ' Assign Panels from earlier
  342. '        PanNum = Panels
  343. ' EEE    
  344.     ' Divide by however many the user says are in a carton
  345.         NewNum = Pan3 / PanNum
  346.     ' Round the Result up since we need the next full carton
  347. '        Precision 1
  348. '        NewNum$ = NewNum
  349. '        a$ = RIGHT$(NewNum, 1)
  350. '        if a$ = "0" then goto Done2
  351. '        Precision 0
  352. '        NewNum2 = NewNum
  353. '        NewNum = NewNum2 + 1
  354.      Done2:
  355.         Precision 1
  356.         NewNum3 = NewNum
  357.         NewNum2$ = NewNum3,"cts"
  358.         Precision 2
  359.     ' Select Object when Created is on
  360.         Sys(242) = 1
  361.         '
  362.         ' Print Panels at info box bottom
  363.         >Text2D
  364.         {
  365.         <justification 2
  366.         <size [TH]
  367.         <text "Panels"
  368.         <angle 0
  369.         <Pointxyz [TH*3.5], [-CurY-TH*2], 0
  370.         }
  371.     ' Select Object when Created is off
  372.         Sys(242) = 0
  373.     ' Get Current Max X values to place labled behind the text values
  374.         M = Sys(198)
  375.         M = M + .5
  376.         N = TH * 4 + M
  377.     ' Set Color to Red
  378.         Sys(300) = 255
  379.         Sys(301) = 0
  380.         Sys(302) = 0
  381.     ' Add Carton # and cts
  382.         >Text2D
  383.         {
  384.         <justification 0
  385.         <size [TH]
  386.         <text [NewNum2$]
  387.         <angle 0
  388.         <Pointxyz [M], [-CurY-TH*2], 0
  389.         }
  390.     ' Reset Color
  391.         Sys(300) = ccRed
  392.         Sys(301) = ccGreen
  393.         Sys(302) = ccBlue
  394.         '
  395.     ' Select All
  396.         >SelectAll
  397.         {
  398.         }
  399.     ' Copy Area Box back into main drawing
  400.                 >Copy
  401.                 {
  402.                 }
  403.             '
  404.             ' Close Temp Drawing
  405.                 >Close
  406.                 {
  407.                 <SaveChanges 0
  408.                 }
  409.             '
  410.             ' Refresh the Screen
  411.                 >Regenerate
  412.                 {
  413.                 }
  414.             ' Back to Layer 11
  415.                 Layer(11) = 14
  416.                 '
  417.             ' Paste the info box in again
  418.                 >Paste
  419.                 {
  420.                 <Type 0
  421.                 ' 0 = Changeable scale (based on distance between handles 1 and 2); 1 = Fixed scale (always paste at original size)
  422.                 <SelectOnly 0
  423.                 ' 
  424.                 ' 0 = select the pasted object; 1 = leave the pasted object unselected
  425.                 <pointxyz 0,0,0
  426.                 }
  427.                 '
  428.             ' Select Layer 11
  429.                 >SelectLayer
  430.                 {    
  431.                 <Layer 11
  432.                 }
  433.             ' Get Min and Max of the current Selection
  434.                 MinX = Sys(196) 
  435.                 MinY = Sys(197) 
  436.                 MaxX = Sys(198) 
  437.                 MaxY = Sys(199) 
  438.             ' Set Handle
  439.                 >SetHandle
  440.                 {
  441.                 <pointxyz [MinX,MinY],0
  442.                 <pointxyz [MaxX,MinY],0
  443.                 }
  444.             ' Loop for Moving Box from Layer 11 to the current layer
  445.                 for a = 1 to Sys(9)
  446.                     getattr a, type, select, laynum, group, red, green, blue
  447.                     if laynum = 11 then laynum = 10
  448.                         Putattr a, type, select, laynum, group, red, green, blue
  449.                     next a
  450.             ' Switch to and Name Layer 10
  451.                 Sys(3) = 10
  452.                 Sys$(93) = "6x6 Material Boxes"
  453.                 '    
  454.             ' Silent Mode Off
  455.                 Sys(36) = 0
  456.                 '
  457.             ' Refresh the Drawing
  458.                 >Regenerate
  459.                 {
  460.                 }
  461.             ' Move the Box
  462.                 >Move
  463.                 {
  464.                 <Type 0
  465.                 }
  466.                 '
  467.             ' Refresh the Screen to see text in area box
  468.                 >Regenerate
  469.                 {
  470.                 }
  471.                 '
  472.             ' Deselect the Box after it's been placed
  473.                 >PointSelect
  474.                 {
  475.                 <Type 0
  476.                 <pointxyz -100, -100, 100
  477.                 }
  478.                 '
  479.             ' Return to previous Current Layer
  480.                 Sys(3) = CurLay
  481.                 '
  482. end
  483.  
  484.     ' Select Layer 10
  485.         >SelectLayer
  486.         {    
  487.         <Layer 10
  488.         }    
  489.         '
  490.     ' Set Info Box Handles
  491.         >SetHandle
  492.         {
  493.         <Pointxyz [-TH*2], [-CurY], 0
  494.         <Pointxyz [TH*10], [-CurY], 0
  495.         }
  496.         ' Loop for Moving Box from Layer 11 to the LLay layer
  497.             for a = 1 to Sys(9)
  498.                 getattr a, type, select, laynum, group, red, green, blue
  499.                 if laynum = 11 then laynum = LLay
  500.                     Putattr a, type, select, laynum, group, red, green, blue
  501.                 next a
  502.         if LLay = 10 then
  503.         ' Make Layer 10 Current and name it
  504.             Layer(10) = 14
  505.             Sys$(93) = "6x6 Info Boxes"
  506.         else
  507.         ' Make Layer 14 Current and name it
  508.             Layer(14) = 14
  509.             Sys$(93) = "6x6 Summary Box"
  510.         endif
  511.         ' Silent Mode Off
  512.             Sys(36) = 0
  513.         '
  514.         ' Refresh the Screen
  515.             >Regenerate
  516.             {
  517.             }
  518.             '    
  519.         ' Move the Box
  520.             >Move
  521.             {
  522.             <Type 0
  523.             }
  524.             '
  525.         ' Refresh the Screen
  526.             >Regenerate
  527.             {
  528.             }
  529.             '
  530.         ' Deselect the Box after it's been placed
  531.             >PointSelect
  532.             {
  533.             <Type 0
  534.             <pointxyz -100, -100, 100
  535.             }
  536.             '
  537.         ' Return to previous Current Layer
  538.             Sys(3) = CurLay
  539.             '
  540. ' Program Finished at this point
  541. end
  542.